restrict osm timestamps. (#1107)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Fri, 12 May 2023 15:48:24 +0000 (09:48 -0600)
committerGitHub <noreply@github.com>
Fri, 12 May 2023 15:48:24 +0000 (09:48 -0600)
osm consumers may not accept fractional seconds, but all should
support whole seconds.
osm consumers may not accept time zone designations other than Z,
but all should support time zone designation Z.
See https://github.com/osmcode/osmium-tool/issues/267

osm.cc

diff --git a/osm.cc b/osm.cc
index 91365ef95f5410037c350bb11f0684f3fa407504..1409cc831ea9827c151a8f442ea0407854d92611 100644 (file)
--- a/osm.cc
+++ b/osm.cc
@@ -718,7 +718,8 @@ OsmFormat::osm_waypt_disp(const Waypoint* waypoint)
   fout->writeAttribute(QStringLiteral("lat"), QString::number(waypoint->latitude, 'f', 7));
   fout->writeAttribute(QStringLiteral("lon"), QString::number(waypoint->longitude, 'f', 7));
   if (waypoint->creation_time.isValid()) {
-    fout->writeAttribute(QStringLiteral("timestamp"), waypoint->CreationTimeXML());
+    // osm readers don't uniformally support fractional seconds, and may only accept time zone designation Z.
+    fout->writeAttribute(QStringLiteral("timestamp"), waypoint->creation_time.toUTC().toString(Qt::ISODate));
   }
 
   if (waypoint->hdop) {